package com.zhijian.wharf.controller.web;

import com.zhijian.response.annotation.Response;
import com.zhijian.util.page.Page;
import com.zhijian.wharf.annotation.LogOperation;
import com.zhijian.wharf.entity.vo.request.AisSearchVo;
import com.zhijian.wharf.entity.vo.response.AisVo;
import com.zhijian.wharf.service.AisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 船舶AIS数据 控制层
 *
 * @author auto
 * @version 1.0
 * @date 2024-07-11 22:14:11
 */
@Slf4j
@Controller
//@Api(tags = "船舶AIS数据")
public class AisController {

    @Autowired
    private AisService service;

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @Response
    @GetMapping("/ais/{id}")
    @ApiOperation("根据id查询")
    @LogOperation("查询船舶AIS数据详情")
    public AisVo selectById(@PathVariable("id") Long id) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), id);
        return service.selectVoById(id);
    }

    /**
     * 分页查询
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/ais/page")
    @ApiOperation("分页查询")
    @LogOperation("分页查询船舶AIS数据")
    public Page<AisVo> selectByCondition(@RequestBody(required = false) AisSearchVo param) {
        if (param == null)
            param = AisSearchVo.builder().build();
        log.info("{} - {}| query info", this.getClass().getSimpleName(), param);
        return service.selectPage(param);
    }

}